function manyToOne(arr,empty=[]){//递归
    for(let item of arr){
        if(Array.isArray(item)){
            manyToOne(item,empty);
        }else {
            empty.push(item);
        }
    }
    return empty;
}
console.log(manyToOne([1,2,[3,4,[5]]])) 

console.log([1,2,[3,4,[5]]].flat(Infinity))